#####################################################################################################################
# CHECK HOW MANY PEOPLE WERE RESCUED BY EACH RESCUER TYPE AND WHETHER THE DIFFERENCES ARE STATISTICALLY SIGNIFICANT #
#####################################################################################################################
# Author: Kasia Nalewajko
# First created: 2 February 2023
# Replicated: 9 June 2024

rm(list = ls())

# LOAD PACKAGES -----------------------------------------------------------

if (!require("dplyr")) install.packages("dplyr")

# LOAD DATA ---------------------------------------------------------------

load("./00 SUBMITTED/00 APSR final/04 replication_files/01 data/RANfrance.Rda")

# VISUALISE TABLE --------------------------------------------------------------

sum <- frran_hh %>% 
  group_by(type) %>% 
  summarise(sum_rescuers = n(),
            avg_rescuers = mean(rescuers_no, na.rm = TRUE),
            avg_rescuees = mean(rescuees_no, na.rm = TRUE))
sum

# Conduct ANOVA and Tukey tests ------------------------------------------------

dat.aov <- aov(rescuees_no ~ type, data=frran_hh)
summary(dat.aov)
TukeyHSD(dat.aov, conf.level=.95)

dat.aov <- aov(rescuers_no ~ type, data=frran_hh)
summary(dat.aov)
TukeyHSD(dat.aov, conf.level=.95)

t.test(rescuees_no ~ resister, data=frran_hh)
dat.aov <- aov(rescuees_no ~ type, data=frran_hh)
summary(dat.aov)
TukeyHSD(dat.aov, conf.level=.95)


